package com.pur.zsms.turnover.service.impl;

import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import net.sf.cglib.beans.BeanCopier;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.pur.zsms.common.exception.GenericException;
import com.pur.zsms.common.support.PageController;
import com.pur.zsms.common.support.PaginationSupport;
import com.pur.zsms.common.util.PubFun;
import com.pur.zsms.common.util.pub.FDate;
import com.pur.zsms.cost.vo.CostVo;
import com.pur.zsms.financing.vo.FinancingVo;
import com.pur.zsms.foodmanage.food.po.FoodPo;
import com.pur.zsms.foodmanage.food.vo.FoodVo;
import com.pur.zsms.matermanage.mater.po.MaterLevelPo;
import com.pur.zsms.ordercustommanage.vo.OrderCustVo;
import com.pur.zsms.ordercustommanage.web.OrderCustControllor;
import com.pur.zsms.pmsnmanage.user.dao.IUserDao;
import com.pur.zsms.timecontrol.dao.ITimeControlDao;
import com.pur.zsms.timecontrol.po.TimeControlPo;
import com.pur.zsms.timecontrol.service.ITimeControlService;
import com.pur.zsms.turnover.dao.ITurnoverDao;
import com.pur.zsms.turnover.po.TurnoverPo;
import com.pur.zsms.turnover.po.TurnoverSubPo;
import com.pur.zsms.turnover.service.ITurnoverService;
import com.pur.zsms.turnover.vo.TurnoverVo;

@Service("turnoverService")
public class TurnoverServiceImpl implements ITurnoverService {
	@SuppressWarnings("unused")
	private static final Logger log = LoggerFactory.getLogger(OrderCustControllor.class);
	String msg = "";

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	@Resource(name = "turnoverDao")
	private ITurnoverDao turnoverDao;

	@Override
	public void addTurnoverPo(TurnoverPo po) throws GenericException {
		turnoverDao.addTurnoverPo(po);
	}

	public void addTurnoverSub(TurnoverSubPo turnoverSubPo) throws GenericException {
		turnoverDao.addTurnoverSubPo(turnoverSubPo);
	}

	public void updateTurnoverPo(TurnoverPo turnoverPo) throws GenericException {
		turnoverDao.updateTurnoverPo(turnoverPo);
	}

	public int getMaxAddId(FinancingVo tFinancingVo) throws GenericException {
		List<Object> list = turnoverDao.getMaxAddId(tFinancingVo);
		if (list != null && list.size() > 0) {
			Object a = list.get(0);
			if (a != null && !a.equals("") && !a.equals("0")) {
				return Integer.valueOf(a.toString()) + 1;
			} else {
				return 1;
			}
		} else {
			return 1;
		}
	}

	@Override
	public PaginationSupport listTurnoverSubList(PageController pageController, TurnoverVo turnoverVo)
	        throws GenericException {
		return turnoverDao.listTurnoverSubList(pageController, turnoverVo);
	}

	public PaginationSupport turnoverDetailForManager(PageController pageController, TurnoverVo turnoverVo) throws GenericException {
		return turnoverDao.turnoverDetailForManager(pageController, turnoverVo);

	}
}
